package com.fyt.reachgo.controller;



import cn.hutool.core.lang.UUID;
import com.fyt.reachgo.domain.Result;
import com.fyt.reachgo.domain.TravelRequest;
import com.fyt.reachgo.service.TravelRequestService;
import com.fyt.reachgo.service.TravelRouteService;
import com.fyt.reachgo.service.impl.OaService;
import com.fyt.reachgo.utils.UserHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/travel")
public class TravelController {

    @Autowired
    private OaService oaService;

    @Autowired
    private TravelRequestService travelRequestService;

    @PostMapping("/plan")
    public Result planTravel(@RequestBody TravelRequest request) {
        // 生成唯一请求id
        request.setId(UUID.fastUUID().toString());
        // 分配用户id
        request.setUserId(UserHolder.getUser().getUserId());
        System.out.println("controller : " + request);
        return oaService.generateRoute(request);
    }
}
